/**
 * 详情对话框
 */
var TransportReceiptInfoDlg = {
    data: {
        dispatchNumber: "",
        carnumber: "",
        getUnitid: "",
        getUnit: "",
        getLocation: "",
        getLocationid: "",
        fileId: "",
        time: "",
        username: "",
        gps: "",
        tstate: "",
        num: "",
        volume: "",
        version: "",
        deptId: "",
        deliverId: "",
        createTime: "",
        updateTime: "",
        createUser: "",
        updateUser: ""
    }
};

layui.use(['form', 'admin', 'ax', 'upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/orderTransportDispatch/editzhuangzaifile", function (data) {
			if(data.success){
				parent.submit = 1
	            Feng.success("更新成功！");
	        	var Index = parent.layer.getFrameIndex(window.name);
            	parent.layer.close(Index);
			} else {
            	Feng.error("更新失败！" + data.message)
			}
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
		data.field.dispatchNumber = Feng.getUrlParam("dispatchNumber")
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    
    upload.render({
        elem: '#imgHead'
        , url: Feng.ctxPath + '/orderTransportDispatch/upload'
        , before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#avatarPreview').attr('src', result);
            });
        }
        , done: function (res) {
            $('#fileId').val(res.data.fileId);
        }
        , error: function () {
            Feng.error("上传失败！");
        }
    });

    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

});